<%-- 
    Document   : ValidateLogin
    Created on : Jun 16, 2012, 7:08:54 PM
    Author     : praneeth
--%>

<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Validate Login JSP Page</title>
    </head>
    <body>
      
        <% String uid= request.getParameter("username");
            String pwd= request.getParameter("password");
       // String role= request.getParameter("role");
        session.setAttribute("userid", uid);
      
        String q1="select * from Login where userid='"+uid+"' and PASSWORD='"+pwd+"'";

             //  out.println(q1);
        Connection con=null;
        Statement stmt=null;
        ResultSet rs=null;
        
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con=DriverManager.getConnection("jdbc:odbc:egasdsn");
        
        stmt=con.createStatement();
        rs=stmt.executeQuery(q1);
        
        if(rs.next()){
            
                           String uidfromdb= rs.getString("userid");
                           
                                %>        
                                <%@include file="ConsumerPage.jsp" %>             
        <% 
        
        out.println("<br><h4>Hi   "+uid.toUpperCase()+"</h4>");
                               
                       }
               else{
            
        %> <%@include file="index.jsp" %>
            %>
        
        <%
            out.println("Invalid user");
               }
        

            %>        
      
    </body>
</html>
 